import routes, { RouteState } from './routes'
import React from 'react'
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'

const renderView = (routes: RouteState[]) => {
	return <>
		{
			routes.length > 0 && routes.map((v, i) => {
				return <Route key={i} path={v.path} element={<v.element></v.element>}>
					{ v.children && renderView(v.children) }
				</Route>
			})
		}
	</>
}

const Index: React.FC = () => {
	return <>
		<Router>
			<Routes>
				{renderView(routes)}
			</Routes>
		</Router>
	</>
}


export default Index